<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="https://www.wlansq.cn/public/Index/js/jquery.min.js"></script>
<script>
<?PHP
function get_curl($url,$post=0,$referer=0,$cookie=0,$header=0,$ua=0,$nobaody=0,$timeout=5,$location=0){
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
	$httpheader[] = "Accept: */*";
	$httpheader[] = "Accept-Encoding: gzip,deflate,sdch";
	$httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
	$httpheader[] = "Connection: close";
	$httpheader[] = "x-requested-with: XMLHttpRequest";
	curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
	if($post){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		$httpheader[] = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8";
	}
	curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
	if($header){
		curl_setopt($ch, CURLOPT_HEADER, TRUE);
	}
	if($cookie){
		curl_setopt($ch, CURLOPT_COOKIE, $cookie);
	}
	if($referer){
		if($referer==1){
			curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
		}else{
			curl_setopt($ch, CURLOPT_REFERER, $referer);
		}
	}
	if($ua){
		curl_setopt($ch, CURLOPT_USERAGENT,$ua);
	}else{
		curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.4355.400 QQBrowser/9.7.12672.400');
	}
	if($nobaody){
		curl_setopt($ch, CURLOPT_NOBODY,1);
	}
	curl_setopt($ch, CURLOPT_ENCODING, "gzip");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	if($location)curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 2);
	$ret = curl_exec($ch);
	curl_close($ch);
	return $ret;
}

$uid = $_GET['uid'];
$data=get_curl('https://www.iesdouyin.com/share/user/'.$uid,0,0,0,0,$_SERVER['HTTP_USER_AGENT'],0,0,1);
preg_match("/tac='(.*?)'/", $data, $res);
$tac = $res[1];
preg_match("/dytk:.*'(.*)'/", $data, $res);
$dytk = $res[1];
$file=str_replace('{$UA}',$_SERVER['HTTP_USER_AGENT'],file_get_contents('douyin_fun.js'));
$file=str_replace('{$uid}',$uid,$file);
$file=str_replace('{$tac}',$tac,$file);
$file=str_replace('{$dytk}',$dytk,$file);
echo $file;
echo PHP_EOL;
echo "var signature=generateSignature(".$uid.");";
echo "var dytk='".$dytk."';";
echo "var json={}; json.signature = signature; json.aid=1128; json.dytk=dytk;";
echo "var res = JSON.stringify(json, null, \"\t\");";
echo "document.write(res);";
?>
</script>
</body>
</html>
